package model

import (
	"mlgmd.com/hearsay/entities"
	"xorm.io/xorm"
)

type Message struct {
	entities.Message `xorm:"extends"`
	FromUser         entities.User `xorm:"extends" json:"fromUser"`
}

func (Message) Query(DB xorm.Interface) *xorm.Session {
	return DB.Table([]any{&entities.Message{}, "m"}).
		Join("INNER", []any{&entities.User{}, "fu"}, "fu.id = m.from_user_id")
}
